perm filename LECT10.TEX[ARK,TEX] blob sn#766836 filedate 1984-08-22 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	% copyright 1984 by Arthur Keller ... All rights reserved
C00010 00003	\section*{Assignment}
C00011 ENDMK
CāŠ—;
% copyright 1984 by Arthur Keller ... All rights reserved
\chapter{Tables}

%Wed, August 22

%11am-12n
%Tables
%>settabs

%1-2pm
%<lab assignment 7>

\TeX\ has two basic ways to align columns of text.
One uses the concept of tabbing; the other, which is more automatic, uses
the command \cmd{halign}.

To use tabbing, you first have to specify where the tab stops are to be
set, as though you were using a typewriter.
The basic way to do this is with the command \cmd{settabs $n$ \bs
columns}, where $n$ is the number of columns of equal width into which
the page is to be divided.
For example, \cmd{settabs 4 \bs columns} divides the width of the page
into quarters.

Each line of text which is to include tabbing commands must then begin
with \cmd{+} (backslash-plus), and must end with \cmd{cr}.
The ampersand character ({\tt \&}) is then used to place the text which
follows it at the beginning of the next column.
Note that the first {\tt \&} will always move \TeX\ to the beginning of
the first column, {\sl no matter how wide the text in the first column
was}, even if this means backing up across the page rather than moving
forward.
In this regard, \TeX's tabbing is unlike that of a typewriter, where a tab
command always moves you to the right to the next physical tab stop; \TeX\
moves you to the next {\sl logical} tab stop.

Let's look at some examples:
\begin{tabbing}
\hskip.25\hsize\=\hskip0.25\hsize\=\hskip0.25\hsize\=\hskip0.25\hsize\=\kill
Columns One\>Two\>Three\>Four
\end{tabbing}
We can skip the first column by putting an {\tt \&} at the beginning
of the text, which causes us to move immediately to the second column.
In other words, \cmd{+\& Skip the first\bs cr} produces
\begin{tabbing}
\hskip0.25\hsize\=\hskip0.25\hsize\=\hskip0.25\hsize\=\hskip0.25\hsize\=\kill
\>Skip the first
\end{tabbing}
Notice that we didn't need any extra {\tt \&} after the second column;
we just terminated the line with a \cmd{cr}.  If we wanted to put text
in the right margin, we can just begin the line with four {\tt \&}:
\cmd{+\&\&\&\&Over the edge\bs cr}
 results in:
\begin{tabbing}
\hskip0.25\hsize\=\hskip0.25\hsize\=\hskip0.25\hsize\=\hskip0.25\hsize\=\kill
\>\>\>\>Over the edge
\end{tabbing}

Another way to use the \cmd{settabs} command is to define a template.
The template tells \TeX\ how wide to make each column; thus, we must
search all the entries in our table to find the widest entry in each
column.
(Obviously they won't all necessarily be from the same row of the table.)

Suppose that our table consisted of two rows, one of which is ``May''
followed by ``chance of rain,'' and the other of which is ``December''
followed by ``snow,'' and a header consisting of the words ``Month'' and
``Weather.''
Then the widest entry in the first column is ``December,'' while the
widest in the second is ``chance of rain.''
Let's also suppose that we want 1 quad of space between the columns for
the month and the weather.
Our template would then look as follows:
\par\smallskip\noindent
\cmd{settabs \bs+ December\bs quad\&Chance of rain\bs cr}
\par\smallskip\noindent
where the \cmd{+}
begins the template and the \cmd{cr} ends it.
The entries in our table would then be typed as follows:
\par\smallskip\noindent
\cmd{+Month\&Weather\bs cr\hfil\break \bs+ May\&Chance of rain\bs
cr\hfil\break \bs+December\&Snow\bs cr}\hfil\break
\par\smallskip\noindent

The result is as follows:
\begin{tabbing}
December\quad\=Chance of rain\kill
Month\>Weather\\
May\>Chance of rain\\
December\>snow
\end{tabbing}

Notice that by specifying the spacing in the template, \TeX\ will
automatically set the tab stops so that there's the requested amount of
space between the columns.
It doesn't matter whether we put the \cmd{quad} before or after the {\tt
\&}; the result would be the same in either case.
Each \cmd{settabs} command stays in effect until the next one is given,
except that a \cmd{settabs} command given within a grouping delimited by
brackets disappears once you exit that grouping.

There are a number of ways to dress up tables.  To emphaize the header, we
may want to have it appear in boldface.  To do this, we have to give the
command \cmd{bf} before the text of each column, since each column in an 
alignment is implicitly enclosed in brackets.  Thus the first entry after the
template would be:
\par\smallskip\noindent
\cmd{+\bs bf Month\&\bs bf Weather\bs cr}
\par\smallskip\noindent
We could also set the header off from the rest of the table by including a
\cmd{smallskip} between the header and the first regular entry.  If we
wanted each entry in the table to come out centered in its column, we could
redefine the template by placing an \cmd{hfil} on both sides of each entry.
(To have them flush left, we put an \cmd{hfil} on the right side, and vice
versa.)

\section*{Assignment}

Reading for this lecture:
The {\sl \TeX book}, Chapter~22, pages~231--234.

Assignment for this lecture:
Exercise~22.1 (page~233) from the {\sl \TeX book}.